<?php

/**
 * Milestones filter form base class.
 *
 * @package    mysmartmanager
 * @subpackage filter
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 24171 2009-11-19 16:37:50Z Kris.Wallsmith $
 */
abstract class BaseMilestonesFormFilter extends BaseFormFilterDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'name'          => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'createdate'    => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
      'startdate'     => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
      'enddate'       => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
      'notes'         => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'projectid'     => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Project'), 'add_empty' => true)),
      'estimatedcost' => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'actualcost'    => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'createby'      => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Users'), 'add_empty' => true)),
      'version'       => new sfWidgetFormFilterInput(array('with_empty' => false)),
    ));

    $this->setValidators(array(
      'name'          => new sfValidatorPass(array('required' => false)),
      'createdate'    => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
      'startdate'     => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
      'enddate'       => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
      'notes'         => new sfValidatorPass(array('required' => false)),
      'projectid'     => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Project'), 'column' => 'projectid')),
      'estimatedcost' => new sfValidatorSchemaFilter('text', new sfValidatorNumber(array('required' => false))),
      'actualcost'    => new sfValidatorSchemaFilter('text', new sfValidatorNumber(array('required' => false))),
      'createby'      => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Users'), 'column' => 'loginid')),
      'version'       => new sfValidatorPass(array('required' => false)),
    ));

    $this->widgetSchema->setNameFormat('milestones_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Milestones';
  }

  public function getFields()
  {
    return array(
      'milestoneid'   => 'Number',
      'name'          => 'Text',
      'createdate'    => 'Date',
      'startdate'     => 'Date',
      'enddate'       => 'Date',
      'notes'         => 'Text',
      'projectid'     => 'ForeignKey',
      'estimatedcost' => 'Number',
      'actualcost'    => 'Number',
      'createby'      => 'ForeignKey',
      'version'       => 'Text',
    );
  }
}
